package com.example.juccode.juc01threadpool.demo04;

import com.example.juccode.juc01threadpool.demo04.Task.ForkJoinTask01;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

/**
 * @description: 分隔任务 合并结果 的框架
 * @date 2025/11/4 15:36
 */
public class ForkJoinDemo {
    public static void main(String[] args) {
        ForkJoinTask01 forkJoinTask = new ForkJoinTask01(1, 100);
        //创建任务
        ForkJoinPool threadPool = new ForkJoinPool();
        //提交任务
        ForkJoinTask<Integer> future = threadPool.submit(forkJoinTask);
        try {
            //获取结果
            System.out.println("结果：" + future.get());
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            threadPool.shutdown();
        }

    }
}
